package com.offcn.oauth.interceptor;

import com.offcn.oauth.token.AdminToken;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TokenRequestInterceptor implements RequestInterceptor {

    /**
     * 在远程调用的时候 通过requestTemplate来发送请求
     * @param requestTemplate
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
        String token = AdminToken.createAdminToken();
        System.out.println("bearer " + token);
        requestTemplate.header("Authorization","bearer " + token);
    }
}
